// pages/subPages/withdraw/withdraw.js
const  app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    appellation: '',
    mobileNumber: '',
    problem: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options);
    this.setData({
      maxMoney: options.commission
    })
  },


  onChange(event) {
    console.log(event);
    if(event.detail == this.data.radio) return
    this.setData({
      radio: event.detail,
      zhifubaoNum: '',
      weixinNum: '',
    });
  },
  submit(){
    const {appellation, mobileNumber, problem } = this.data;
    if(!appellation) return  wx.showToast({ icon: 'none', title: '请告诉我该怎么称呼您', })
    if(!mobileNumber) return  wx.showToast({ icon: 'none', title: '请填写联系电话', })
    if(!problem) return  wx.showToast({ icon: 'none', title: '请填写投诉建议内容', })
    wx.request({
      url: app.globalData.url + '/app/suggestComplaint',
      method: 'POST',
      data: {
        appellation, 
        mobileNumber, 
        problem,
        consumerId: app.globalData.userInfo.consumerId
      },
      header: {
        'Accept': 'application/json',
        'consumerId': app.globalData.userInfo.consumerId
      },
      success: function (res) {
        if (res.data.code == 200) { 
          wx.showToast({
            title: '已收到您的建议，请耐心等候客服反馈',
            success: function () {
              wx.switchTab({
                //页面跳转到个人中心
                url: '/pages/user/user',
              })
            },
          })
        } else {
          wx.showToast({
            icon: 'none',
            title: res.data.msg,
          })
        }
      }
    })
  }
})